package lol.clann.minecraft.springboot.remap.remappers;

import java.util.*;

/**
 * 与InheritanceMap相比,更加节省内存
 *
 * @author pyz
 * @date 2019/7/4 9:44 AM
 */
public class InheritanceMap {
    protected final List<String> emptyList = new ArrayList<>();
    protected final Map<String, List<String>> _inheritanceMap = new HashMap<>();

    public boolean hasParents(String className) {
        return _inheritanceMap.containsKey(className);
    }

    public List<String> getParents(String className) {
        return _inheritanceMap.get(className);
    }

    public void setParents(String className, Collection<String> parents) {
        if (parents == null || parents.isEmpty()) {
            _inheritanceMap.put(className, emptyList);
        } else {
            _inheritanceMap.put(className, new ArrayList<>(parents));
        }
    }
}
